package cn.tedu.csmall.product.schedule;

import cn.tedu.csmall.product.service.BrandService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 缓存计划任务类
 *
 * @author Chen
 * @since 2023/2/13 17:29:29
 */
@Slf4j
@Component
public class CacheSchedule {

    private BrandService brandService;

    @Autowired
    public CacheSchedule(BrandService brandService) {
        this.brandService = brandService;
    }

    public CacheSchedule() {
        log.debug("创建计划任务类对象：CacheSchedule");
    }

    @Scheduled(fixedRate = 1000 * 60 * 60 * 24L)
    public void run() {
        log.debug("开始执行计划任务...");
        brandService.rebuildCache();
    }

}
